#include "AnimMontageUtils.h"
#include "BlendAttached.h"

BlendAttached::BlendAttached(QObject *parent)
{

}

float BlendAttached::alpha() const
{
    return m_alpha;
}

void BlendAttached::setAlpha(float newAlpha)
{
    if (qFuzzyCompare(m_alpha, newAlpha))
        return;
    m_alpha = newAlpha;
    emit alphaChanged();
}

QStringList BlendAttached::getNodeList() const
{
    return nodeList;
}

void BlendAttached::setNodeList(const QStringList &newNodeList)
{
    if (nodeList == newNodeList)
        return;
    nodeList = newNodeList;
    emit nodeListChanged();
}

QObject *BlendAttached::getFilterNode() const
{
    return filterNode;
}

void BlendAttached::updateFilter()
{
    nodeList.clear();
    auto ret = AnimMontageUtils::groupById(filterNode);
    nodeList = ret.keys();
}

void BlendAttached::setFilterNode(QObject *newFilterNode)
{
    if (filterNode == newFilterNode)
        return;
    filterNode = newFilterNode;
    updateFilter();
    emit filterNodeChanged();
}

BlendAttached *Blend::qmlAttachedProperties(QObject *object)
{
    return new BlendAttached(object);
}
